package com.best.oasis.settlement.dao.security;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;

import com.best.oasis.settlement.common.entity.security.RoleGroup;
import com.best.oasis.settlement.common.so.security.RoleGroupSO;
import com.best.oasis.settlement.dao.base.BaseDaoImpl;
import com.best.oasis.settlement.util.page.PageList;

@Repository
public class RoleGroupDaoImpl  extends BaseDaoImpl<RoleGroup, Long> implements RoleGroupDao {

	public RoleGroupDaoImpl() {
		super(RoleGroup.class);
	}
	@SuppressWarnings("unchecked")
	@Override
	public PageList<RoleGroup> getPageList(RoleGroupSO so) {
		PageList<RoleGroup> result = new PageList<RoleGroup>(so);
		List<RoleGroup> list;
		int fullListSize;

		RowBounds rowBounds = new RowBounds((so.getPageNumber() - 1) * so.getObjectsPerPage(), so.getObjectsPerPage());
	     
	    list = getSqlSessionTemplate().selectList(getStatementPrefix() + POSTFIX_GET_LIST_BY_SO ,so,rowBounds);
	    fullListSize = getPaginatedListCount(so);
	     
	    result.setFullListSize(fullListSize);
	    result.setList(list);
	     
	    return result;
	}
	
	@SuppressWarnings("unchecked")
	public List<RoleGroup> getAllByName(RoleGroupSO so){
		
		List<RoleGroup> retList = getSqlSessionTemplate().selectList(getStatementPrefix() + POSTFIX_GET_LIST_BY_SO ,so);
        return retList;
	}
    @Override
    @SuppressWarnings("unchecked")
    public List<RoleGroup> getRoleGroupsByUserid(Long userID) {
        List<RoleGroup> result = getSqlSessionTemplate().selectList(getStatementPrefix() + "getRoleGroupsByUserID" ,userID);
        return result;
    }
}
